package com.bml.client.secret.demo.CAS;

import sun.misc.Unsafe;

public class CasTest {

    public static void main(String[] args) {

        Entity entity = new Entity();
        Unsafe unsafe = UnsafeFactory.getUnsafe();
        long offset = UnsafeFactory.getFieldOffset(unsafe, Entity.class, "x");
        System.out.println(offset);
        unsafe.compareAndSwapInt(entity,offset,0,3);
        System.out.println(entity.getX());


    }


    static class Entity{
        long x;

        public long getX() {
            return x;
        }
    }
}
